package com.chatplus.application.service.basedata.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chatplus.application.dao.basedata.ApiKeyDao;
import com.chatplus.application.domain.entity.basedata.ApiKeyEntity;
import com.chatplus.application.service.basedata.ApiKeyService;
import com.chatplus.application.common.logging.SouthernQuietLogger;
import com.chatplus.application.common.logging.SouthernQuietLoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * OpenAI API 业务逻辑实现
 *
 * <p>Table: t_api_key - OpenAI API </p>
 *
 * @author developer
 * @see ApiKeyEntity
 */
@Service
public class ApiKeyServiceImpl extends ServiceImpl<ApiKeyDao, ApiKeyEntity> implements ApiKeyService {
    private static final SouthernQuietLogger LOGGER = SouthernQuietLoggerFactory.getLogger(ApiKeyServiceImpl.class);

    @Override
    public List<ApiKeyEntity> getEnableApiKeys(String platform, String type) {
        return list(new LambdaQueryWrapper<ApiKeyEntity>()
                .eq(ApiKeyEntity::getPlatform, platform)
                .eq(ApiKeyEntity::getEnabled, true)
                .eq(ApiKeyEntity::getType, type));

    }
}
